﻿@using Microsoft.AspNet.Identity
@model SDCloudSolution.SDCloud.Web.Models.Account.ManageUserClientApplications
  
<h4>Authorization via OAuth2 protocol.</h4>
<hr />
<div>
    <p>
        This credentials used for client application authorization with 
        <a href="https://tools.ietf.org/html/draft-ietf-oauth-v2-31" target="blank" title="Open a OAuth2 specification in new window">OAuth2 protocol</a>.
    </p>
</div>
      
<div>
    @if (Model.Applications.Count > 0)
    {
        <ul>
            @foreach (var application in Model.Applications)
            {
                <li>
                    @if (!application.IsAutoGenerated)
                    {
                        <div>
                            <b>Name:</b>
                            <span>@application.Name</span>
                        </div>
                    }

                    <div>
                        <b>Is active:</b>
                        <span>@application.IsActive</span>
                    </div>

                    <div>
                        <b>Client Id:</b>
                        <pre>@application.ClientId</pre>
                    </div>

                    <div>
                        <b>Client Secret:</b>
                        <pre>@application.ClientSecret</pre>
                    </div>
                </li>
            }
        </ul>
    }
    else
    {
        <p>
            @using (Html.BeginForm(MVC.Account.GenerateClientCredentials()))
            {
                @Html.AntiForgeryToken()

                <button type="submit" class="btn btn-primary">Create client application credentials</button>
            }
        </p>
    }
</div>